home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12275 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  923 b 

  1. Path: Rosie.UH.EDU!ST7JR
  2. From: st7jr@Rosie.UH.EDU (odie garfield)
  3. Newsgroups: comp.lang.c
  4. Subject: Help: 2 short functions
  5. Date: 30 Mar 1996 02:42:44 GMT
  6. Organization: University of Houston
  7. Message-ID: <4ji734$n6v@masala.cc.uh.edu>
  8. Reply-To: st7jr@Rosie.UH.EDU
  9. NNTP-Posting-Host: rosie.uh.edu
  10.  
  11. Hi, I have two functions that I'm not too sure about.
  12. The first one:
  13.  
  14. char *get_filename(void)
  15. {
  16.    char string[20],*stringp;
  17.    scanf("%s",string);
  18.    stringp=&string[0];
  19.    return stringp;
  20. }
  21. I'm want the function to read in a string and return a pointer to that string.
  22. Am I doing it correctly?
  23.  
  24. My second function is related to the first function:
  25.  
  26. FILE *open_file(char *filenamep)
  27. {
  28.    FILE *fp;
  29.    fp=fopen("??????","r");
  30.    return fp;
  31. }
  32. In this 2nd function, I want to open a file using the pointer to a string I
  33. got from the first function. But I don't know exactly how to do this. Any help
  34. would be appreciated. Thanks.
  35.  
  36.